#include "MsgSetDecodeFormat.h"
#include "MsgOK.h"
#include "MsgError.h"
#include "Model.h"
#include "BasicTypes.h"

MsgSetDecodeFormat::MsgSetDecodeFormat( std::string data )
{
	unsigned char tf = data[0];	
	m_treeFormat = (TreeFormat)tf;
}

POutputMessage MsgSetDecodeFormat::Process(Model * model)
{
	if ( (m_treeFormat >= TF_Minimum) && (m_treeFormat <= TF_Maximum) )
	{
		model->SetTreeFormat(m_treeFormat);
		return POutputMessage(new MsgOK());
	} else {
		model->SetTreeFormat(TF_Invalid);
		return POutputMessage(new MsgError(ERR_UNKNOWN_DECODE_FORMAT, *model, NULL));
	}
	return POutputMessage();
}